load("//bazel:mongo_src_rules.bzl", "idl_generator", "mongo_cc_benchmark", "mongo_cc_fuzzer_test", "mongo_cc_integration_test", "mongo_cc_library", "mongo_cc_unit_test")

package(default_visibility = ["//visibility:public"])

exports_files(
    glob([
        "*.h",
        "*.cpp",
    ]),
)

idl_generator(
    name = "bson_validate_gen",
    src = "bson_validate.idl",
    deps = [
        "//src/mongo/db:basic_types_gen",
    ],
)

mongo_cc_library(
    name = "bson_validate",
    srcs = [
        "bson_validate.cpp",
        ":bson_validate_gen",
    ],
    deps = [
        "//src/mongo:base",
        "//src/mongo/bson/column",
        "//src/mongo/db:server_base",
        "//src/mongo/idl:idl_parser",
    ],
)

mongo_cc_unit_test(
    name = "bson_test",
    srcs = [
        "bson_field_test.cpp",
        "bson_iterator_test.cpp",
        "bson_obj_data_type_test.cpp",
        "bson_obj_test.cpp",
        "bson_utf8_test.cpp",
        "bson_validate_test.cpp",
        "bsonelement_test.cpp",
        "bsonobjbuilder_test.cpp",
        "json_test.cpp",
        "oid_test.cpp",
        "ordering_test.cpp",
        "simple_bsonobj_comparator_test.cpp",
    ],
    tags = [
        "mongo_unittest_first_group",
        "server-programmability",
    ],
    deps = [
        "//src/mongo:base",
        "//src/mongo/bson:bson_validate",
        "//src/mongo/bson/column",
        "//src/mongo/db/shard_role/shard_catalog:index_catalog",
    ],
)

mongo_cc_integration_test(
    name = "bson_integration_test",
    srcs = [
        "ugly_bson_integration_test.cpp",
    ],
    deps = [
        "//src/mongo/executor:network_interface",
        "//src/mongo/executor:network_interface_fixture",
        "//src/mongo/rpc:message",
        "//src/mongo/transport:transport_layer_egress_init",
    ],
)

mongo_cc_fuzzer_test(
    name = "bson_validate_fuzzer",
    srcs = [
        "bson_validate_fuzzer.cpp",
        "bson_validate_old.cpp",
    ],
    deps = [
        "//src/mongo:base",
        "//src/mongo/bson:bson_validate",
    ],
)

mongo_cc_fuzzer_test(
    name = "fromjson_fuzzer",
    srcs = [
        "fromjson_fuzzer.cpp",
    ],
    deps = [
        "//src/mongo:base",
        "//src/mongo/bson:bson_validate",
    ],
)

mongo_cc_benchmark(
    name = "bson_bm",
    srcs = [
        "bson_bm.cpp",
    ],
    tags = ["first_half_bm"],
    deps = [
        "//src/mongo:base",
        "//src/mongo/bson:bson_validate",
        "//src/mongo/db/exec/document_value",
    ],
)
